package com.jeesite.modules.app.examinate.extheory.ticket;

import java.io.File;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.modules.conf.AppController;
import com.jeesite.modules.conf.MessageCode;
import com.jeesite.modules.zx.examination.ticket.entity.TexaminationTicket;
import com.jeesite.modules.zx.examination.ticket.service.TexaminationTicketService;
@Controller
@RequestMapping(value = "/app/examinate/ticket/")
public class AppExaminationTicketController {
        @Autowired
        private TexaminationTicketService texaminationTicketService;
        @RequestMapping(value = "download")
    	public void downTexaminationTicker(TexaminationTicket texaminationTicket,HttpServletRequest request,HttpServletResponse response){
        	String id = texaminationTicket.getId();
        	if(StringUtils.isBlank(id)){
        		AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "查询标识");
        		return;
        	}
        	texaminationTicket=texaminationTicketService.get(id);
        	String file=texaminationTicketService.downTexaminationTicker(texaminationTicket);
    		AppController.renderSuccessObject(response, file, MessageCode.SUCCESS_ACK);
    	}
}
